import { Injectable, Logger } from '@nestjs/common';
import { InjectRepository } from '@nestjs/typeorm';
import { Repository } from 'typeorm';
import { ConfigService } from '@nestjs/config';
import { BaseService } from '@wwjCommon/base/base.service';
import { CacheService } from '@wwjCommon/cache/cache.service';
import { LoggingService } from '@wwjCommon/logging/logging.service';
import { UploadService } from '@wwjVendor/upload/upload.service';
import { PayService } from '@wwjVendor/pay/pay.service';
import { SmsService } from '@wwjVendor/sms/sms.service';
import { NoticeService } from '@wwjVendor/notice/notice.service';

@Injectable()
export class WeappDeliveryService extends BaseService<any> {
  private readonly logger = new Logger(WeappDeliveryService.name);

  constructor(
    @InjectRepository(Object)
    protected readonly repository: Repository<any>,
    private readonly cacheService: CacheService,
    private readonly configService: ConfigService,
    private readonly loggingService: LoggingService,
    private readonly uploadService: UploadService,
    private readonly payService: PayService,
    private readonly smsService: SmsService,
    private readonly noticeService: NoticeService,
  ) {
    super(repository);
  }

  /**
   * getIsTradeManaged
   * 对应 PHP: WeappDeliveryService_api::getIsTradeManaged()
   * 逻辑类型: undefined - undefined
   */
  async getIsTradeManaged() {
    // 基于PHP真实逻辑: getIsTradeManaged
    // PHP原文: $result = $this->core_weapp_deliver_service->isTradeManaged($this->site_id);         if ($result[ 'errcode' ] == 0 && $result[ 'is_trade_managed' ]) {...
const result = this.core_weapp_deliver_service.isTradeManaged(this.site_id];
        if (result[ 'errcode' ) == 0 && result[ 'is_trade_managed' )) {
            return true;
  }

  /**
   * getMsgJumpPath
   * 对应 PHP: WeappDeliveryService_api::getMsgJumpPath()
   * 逻辑类型: undefined - undefined
   */
  async getMsgJumpPath(out_trade_no: any) {
    // 基于PHP真实逻辑: getMsgJumpPath
    // PHP原文: $pay_model = new Pay();         $where = array (             [ 'site_id', '=', $this->site_id ],             [ 'out_trade_no', '=', $out_trade_no ]   ...
const pay_model = this.payService;
        const where = (
            [ 'site_id', '=', this.site_id ),
            [ 'out_trade_no', '=', out_trade_no )
        ];
        const pay_info = pay_model.where(where).field('out_trade_no,trade_type,trade_id').findOrEmpty().toArray(];

        // 未获取到交易信息
        if (!pay_info)) {
            return '';
  }
}
